<!DOCTYPE html>
<html>
<head>
    <title>DBC 解析器控制台调试</title>
</head>
<body>
    <h1>DBC 解析器控制台调试</h1>
    <p>打开浏览器控制台查看调试信息</p>
    
    <script src="dbc-parser.js"></script>
    <script>
        console.log('=== DBC 解析器调试开始 ===');
        
        // 测试简单的 VERSION 解析
        console.log('\n1. 测试简单的 VERSION 解析');
        const simpleContent = 'VERSION "EmptyFile.dbc"';
        console.log('测试内容:', simpleContent);
        
        try {
            const tokenizer = new DBCTokenizer(simpleContent);
            console.log('词法分析器创建成功');
            
            const token1 = tokenizer.getNextToken();
            console.log('Token 1:', { type: token1.type, image: token1.image });
            
            const token2 = tokenizer.getNextToken();
            console.log('Token 2:', { type: token2.type, image: token2.image });
            
            const token3 = tokenizer.getNextToken();
            console.log('Token 3:', { type: token3.type, image: token3.image });
            
        } catch (error) {
            console.error('词法分析错误:', error);
        }
        
        // 测试解析器
        console.log('\n2. 测试解析器');
        try {
            const result = parseDBCContent(simpleContent, 'test.dbc');
            console.log('解析成功:', result);
        } catch (error) {
            console.error('解析失败:', error);
        }
        
        // 测试包含多行的内容
        console.log('\n3. 测试多行内容');
        const multiLineContent = `VERSION "EmptyFile.dbc"

NS_ : 
	CM_

BS_:

BU_: TestNode1

BO_ 294 TEST_FRAME: 8 TestNode1
 SG_ PARAM_1 : 7|8@0+ (1,0) [0|0] "" TestNode1
`;

        try {
            const result = parseDBCContent(multiLineContent, 'multi-test.dbc');
            console.log('多行解析成功:', result);
            console.log('帧数量:', result.frames.length);
            if (result.frames.length > 0) {
                console.log('第一个帧:', result.frames[0]);
            }
        } catch (error) {
            console.error('多行解析失败:', error);
        }
        
        console.log('\n=== 调试结束 ===');
    </script>
</body>
</html> 